n,m=map(int,input().split())
matrix=[list(map(int,input().split())) for i in range(0,n)]

# 求一维子数组最大子数组的和
def maxSubArraySum(nums:list)->int:
    dp=[0]*len(nums)
    res=dp[0]=nums[0]
    for i in range(1,len(nums)):
        dp[i]=max(dp[i-1],0)+nums[i]
        res=max(res,dp[i])
    return res

# 将多行子矩阵，压缩为一维数组
def matrixZip(matrix:list[list[int]]):
    cols=len(matrix[0])
    rows=len(matrix)
    zip=[0]*cols
    for c in range(0,cols):
        for r in range(0,rows):
            zip[c]=zip[c]+matrix[r][c]
    return zip

# 算法入口
def getResult(n,m,matrix):
    dp=[]
    for i in range(0,n):
        dp.append(maxSubArraySum(matrix[i]))
        for j in range(i+1,n):
            dp.append(maxSubArraySum(matrixZip(matrix[i:j+1])))
    dp.sort()
    return dp[-1]
print(getResult(n,m,matrix))